#页面类
from Day16zy.Base import Base
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from time import sleep
class Page(Base):
    #定位器
    search_loc=(By.NAME,'key')
    #页面元素的封装
    #登录
    dl = (By.LINK_TEXT, '登录/注册')
    # 点击登录注册
    login=(By.PARTIAL_LINK_TEXT,'登录/注册')
    #点击账号登录
    mimadl=(By.XPATH,'//*[@id="container"]/article/section[1]/div/div[8]/span[1]')
    # 输入账号
    username=(By.ID,'input-username')
    # 输入密码
    passwoed=(By.XPATH,'//*[@id="input-password"]')
    # 勾选协议
    xieyi = (By.XPATH,'//*[@id="checkagree"]')
    # 点击登录
    button=(By.XPATH,'//*[@id="btn-login"]')

    def search(self):
        #登录
        self.click(self.dl)
        sleep(5)
        # 点击账号登录
        self.click(self.mimadl)
        # 输入账号
        self.send_keys(self.username,'17733058407')
        sleep(2)
        # 输入密码
        self.send_keys(self.passwoed, 'li10140910')
        sleep(2)
        # 勾选协议
        self.click(self.xieyi)
        sleep(2)
        # 点击登录按钮
        self.click(self.button)
        sleep(10)

    #业务逻辑
    def luoji_jiuxian_01(self):
        self.open_url('https://m.anjuke.com/bj/')
        self.search()
        sleep(5)